﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SynoManager.DownloadStation.Plugins;
using SynoManager.GUI;

namespace SynoManager.DownloadStation
{
    public partial class PluginsPreferencesPanel : PreferencesPanel
    {
        private readonly DownloadStationService service;
        private ClipboardListenerPlugin clipboardListenerPlugin;
        private InfoBalloon infoBalloonPlugin;

        public PluginsPreferencesPanel()
        {
            InitializeComponent();
        }

        public PluginsPreferencesPanel(DownloadStationService service)
            :this()
        {
            this.service = service;

            clipboardListenerPlugin = (ClipboardListenerPlugin)service.Plugins[typeof(ClipboardListenerPlugin)];
            infoBalloonPlugin = (InfoBalloon)service.Plugins[typeof(InfoBalloon)];

            watchClipboardCheckBox.Enabled = (clipboardListenerPlugin != null);
            watchClipboardCheckBox.Checked = (clipboardListenerPlugin != null) ? clipboardListenerPlugin.Enabled : false;

            showInfoBalloonCheckBox.Enabled = (infoBalloonPlugin != null);
            showInfoBalloonCheckBox.Checked = (infoBalloonPlugin != null) ? infoBalloonPlugin.Enabled : false;
        }

        /// <summary>
        /// Save/Persist the settings on the <see cref="PreferencesPanel"/>.
        /// </summary>
        public override void Save()
        {
            if (clipboardListenerPlugin != null)
                clipboardListenerPlugin.Enabled = watchClipboardCheckBox.Checked;
            infoBalloonPlugin.Enabled = showInfoBalloonCheckBox.Checked;
        }
    }
}
